package com.framework.common.utils;

import io.agora.media.AccessToken;
import io.agora.media.RtcTokenBuilder;
import io.agora.media.Utils;

public class AgoraHelper {

    /**
     * 获取声网会话 token
     * @param channelName 频道名称
     * @param uid 用户名
     * @param expiredSeconds token过期时间
     * @param appId 应用ID
     * @param appCertificate 密钥/证书字符串
     * @return
     */
    public static String createRtcToken(String channelName,Integer uid,Integer expiredSeconds,String appId,String appCertificate) {
        RtcTokenBuilder token = new RtcTokenBuilder();
        
        int timestamp = (int) (System.currentTimeMillis() / 1000 + expiredSeconds);
        String result = token.buildTokenWithUid(appId, appCertificate,
                channelName, uid, RtcTokenBuilder.Role.Role_Publisher, timestamp);
        return result;
    }
}
